<template>
	<!-- 项目信息 -->
	<div>
		<FormPanel
			ref="FormPanel"
			:list="initForm"
			:cols="2"
			:formType="formType"
			:labelWidth="150"
			:isSubmitBtn="false"
			@formChange="formChangeHandle"
			class="mtop"
		/>
	</div>
</template>

<script>
	import { dictionary } from '@/utils/dictMixin';
	export default {
		mixins: [dictionary],
		model:{
			prop:'pdata',//为了和v-model默认的value区分，将prop改为自定义的名称
			event:'click'//为了和v-model默认的input区分，将event改为click
		},
		props: {
			pdata: {
				type: Object,
				default: () => ({})
			},
			formType:{
				type: String,
				required:true
			}
		},
		data() {
			return {
				initForm: this.initFormFun(),
			};
		},
		methods: {
			//初始化数据
			init() {
				//赋值
				this.initForm.forEach(x => {
					x.initialValue = this.pdata.allForm[x.fieldName];
				});
			},
			formChangeHandle(val) {
				this.pdata.allForm = Object.assign(this.pdata.allForm,val);
				//传递数据到父组件里
				this.$emit('click', this.pdata);
				//触发外部的事件，以标志着本表单已经准备完毕
				this.$emit('formchange', this.pdata);
			},
			saveDialog(){
				this.$refs.FormPanel.SUBMIT_FORM();
			},
			//搜索数据
			initFormFun() {
				return [
					{
						type: 'INPUT',
						label: '项目名称',
						fieldName: 'projectName',
						initialValue: '',
						placeholder:'',
						maxlength:200,
						rules:[
							{required: true, message: '必填', trigger: 'blur' },
							{ min: 0, max: 200, message: '长度在 0 到 200 个字符', trigger: 'blur' }
						],
					},
					{
						type: 'INPUT',
						label: '项目编号',
						fieldName: 'projectCode',
						disabled: true,
						initialValue: '',
						placeholder:'',
					},
					{
						type: 'DATE',
						label: '项目生效日期',
						fieldName: 'projectStartDate',
						valueFormat: 'yyyy-MM-dd',
						disabled: true,
						style: { width: '100%' },
						initialValue: '',
						placeholder:'',
					},
					// {
					// 	type: 'DATE',
					// 	label: '项目生效日期',
					// 	fieldName: 'projectEndDate',
					// 	valueFormat: 'yyyy-MM-dd',
					// 	disabled: true,
					// 	style: { width: '100%' },
					// 	initialValue: ''
					// },
					{
						type: 'TEXT_AREA',
						label: '客户情况描述',
						fieldName: 'customerDesc',
						initialValue: '',
						placeholder:'',
						selfCols:2,
						rows: 2,
						maxlength:500,
						rules:[
							{ min: 0, max: 500, message: '长度在 0 到 500 个字符', trigger: 'blur' }
						],
					},
					{
						type: 'TEXT_AREA',
						label: '项目背景',
						fieldName: 'projectBackgroud',
						initialValue: '',
						placeholder:'',
						selfCols:2,
						rows: 2,
						maxlength:500,
						rules:[
							{ min: 0, max: 500, message: '长度在 0 到 500 个字符', trigger: 'blur' }
						],
					},
					{
						type: 'TEXT_AREA',
						label: '公司发展规划',
						fieldName: 'companyDevelopPlan',
						initialValue: '',
						placeholder:'',
						selfCols:2,
						rows: 2,
						maxlength:500,
						rules:[
							{ min: 0, max: 500, message: '长度在 0 到 500 个字符', trigger: 'blur' }
						],
					},
					{
						type: 'TEXT_AREA',
						label: '车辆更新计划',
						fieldName: 'vehicleUpdatePlan',
						initialValue: '',
						placeholder:'',
						selfCols:2,
						rows: 2,
						maxlength:500,
						rules:[
							{ min: 0, max: 500, message: '长度在 0 到 500 个字符', trigger: 'blur' }
						],
					},
					{
						type: 'TEXT_AREA',
						label: '融资需求',
						fieldName: 'financingNeeds',
						initialValue: '',
						placeholder:'',
						selfCols:2,
						rows: 2,
						maxlength:500,
						rules:[
							{ min: 0, max: 500, message: '长度在 0 到 500 个字符', trigger: 'blur' }
						],
					},
					{
						type: 'TEXT_AREA',
						label: '其他重点采购说明',
						fieldName: 'otherDesc',
						initialValue: '',
						placeholder:'',
						selfCols:2,
						rows: 2,
						maxlength:500,
						rules:[
							{ min: 0, max: 500, message: '长度在 0 到 500 个字符', trigger: 'blur' }
						],
					}
				];
			},
		}
	};
</script>